package org.redmagic.service.domain;

import java.util.Set;
import java.util.TreeSet;

import com.google.common.base.Objects;

public class Property {

	private final String placeholder;
	private final Set<String> tags;
	private final String group;
	
	private String value;
	
	public Property(String placeholder, Set<String> tags, String group) {
		super();
		this.placeholder = placeholder;
		this.tags = new TreeSet<String>(tags);
		this.group = group;
	}
	
	public Property(String placeholder, Set<String> tags, String group, String value) {
		super();
		this.placeholder = placeholder;
		this.tags = new TreeSet<String>(tags);
		this.group = group;
		this.value = value;
	}

	public String getPlaceholder() {
		return placeholder;
	}
	
	public Set<String> getTags() {
		return tags;
	}
	
	public String getGroup() {
		return group;
	}
	
	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	@Override
	public String toString() {
		return Objects.toStringHelper(this)
				         .add("placeholder", placeholder)
				         .add("tags", tags)
				         .add("group", group).toString();
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((group == null) ? 0 : group.hashCode());
		result = prime * result	+ ((placeholder == null) ? 0 : placeholder.hashCode());
		result = prime * result + ((tags == null) ? 0 : tags.hashCode());
		result = prime * result + ((value == null) ? 0 : value.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Property other = (Property) obj;
		if (group == null) {
			if (other.group != null)
				return false;
		} else if (!group.equals(other.group))
			return false;
		if (placeholder == null) {
			if (other.placeholder != null)
				return false;
		} else if (!placeholder.equals(other.placeholder))
			return false;
		if (tags == null) {
			if (other.tags != null)
				return false;
		} else if (!tags.equals(other.tags))
			return false;
		if (value == null) {
			if (other.value != null)
				return false;
		} else if (!value.equals(other.value))
			return false;
		return true;
	}
	
	
}